// 模拟数据文件

// 模拟单词数据
export const mockWords = [
  {
    id: '1',
    text: 'apple',
    pronunciation: '/ˈæpl/',
    definitions: ['苹果（一种水果）'],
    examples: ['I eat an apple every morning.'],
    synonyms: ['fruit', 'pome'],
    antonyms: [],
    partOfSpeech: 'noun',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 5,
    updatedAt: new Date().getTime() - 86400000 * 2
  },
  {
    id: '2',
    text: 'banana',
    pronunciation: '/bəˈnɑːnə/',
    definitions: ['香蕉（一种水果）'],
    examples: ['Bananas are rich in potassium.'],
    synonyms: ['fruit'],
    antonyms: [],
    partOfSpeech: 'noun',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 4,
    updatedAt: new Date().getTime() - 86400000 * 1
  },
  {
    id: '3',
    text: 'cat',
    pronunciation: '/kæt/',
    definitions: ['猫（一种动物）'],
    examples: ['I have a pet cat named Tom.'],
    synonyms: ['feline', 'kitty'],
    antonyms: [],
    partOfSpeech: 'noun',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 3,
    updatedAt: new Date().getTime() - 86400000 * 3
  },
  {
    id: '4',
    text: 'dog',
    pronunciation: '/dɔːɡ/',
    definitions: ['狗（一种动物）'],
    examples: ['Dogs are man\'s best friend.'],
    synonyms: ['canine', 'puppy'],
    antonyms: [],
    partOfSpeech: 'noun',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 6,
    updatedAt: new Date().getTime() - 86400000 * 2
  },
  {
    id: '5',
    text: 'book',
    pronunciation: '/bʊk/',
    definitions: ['书（一种阅读材料）'],
    examples: ['I love reading books.'],
    synonyms: ['publication', 'volume'],
    antonyms: [],
    partOfSpeech: 'noun',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 7,
    updatedAt: new Date().getTime() - 86400000 * 4
  },
  {
    id: '6',
    text: 'computer',
    pronunciation: '/kəmˈpjuːtə(r)/',
    definitions: ['计算机（一种电子设备）'],
    examples: ['I use a computer for work.'],
    synonyms: ['PC', 'laptop'],
    antonyms: [],
    partOfSpeech: 'noun',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 2,
    updatedAt: new Date().getTime() - 86400000 * 1
  },
  {
    id: '7',
    text: 'happy',
    pronunciation: '/ˈhæpi/',
    definitions: ['快乐的（一种情绪）'],
    examples: ['I am very happy today.'],
    synonyms: ['joyful', 'glad'],
    antonyms: ['sad', 'unhappy'],
    partOfSpeech: 'adjective',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 8,
    updatedAt: new Date().getTime() - 86400000 * 3
  },
  {
    id: '8',
    text: 'beautiful',
    pronunciation: '/ˈbjuːtɪfl/',
    definitions: ['美丽的（一种描述）'],
    examples: ['The scenery is beautiful.'],
    synonyms: ['pretty', 'attractive'],
    antonyms: ['ugly'],
    partOfSpeech: 'adjective',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 1,
    updatedAt: new Date().getTime()
  },
  {
    id: '9',
    text: 'run',
    pronunciation: '/rʌn/',
    definitions: ['跑（一种动作）'],
    examples: ['I run every morning.'],
    synonyms: ['jog', 'sprint'],
    antonyms: ['walk', 'stand'],
    partOfSpeech: 'verb',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 9,
    updatedAt: new Date().getTime() - 86400000 * 5
  },
  {
    id: '10',
    text: 'eat',
    pronunciation: '/iːt/',
    definitions: ['吃（一种动作）'],
    examples: ['I eat three meals a day.'],
    synonyms: ['consume', 'ingest'],
    antonyms: ['starve'],
    partOfSpeech: 'verb',
    language: 'en',
    createdAt: new Date().getTime() - 86400000 * 10,
    updatedAt: new Date().getTime() - 86400000 * 6
  }
]

// 模拟单词集数据
export const mockWordSets = [
  {
    id: '1',
    name: '基础词汇',
    description: '英语基础入门词汇',
    wordCount: 10,
    createdAt: new Date().getTime() - 86400000 * 10,
    updatedAt: new Date().getTime() - 86400000 * 2,
    coverImage: 'https://via.placeholder.com/150',
    isPublic: false,
    words: mockWords.slice(0, 5)
  },
  {
    id: '2',
    name: '日常生活词汇',
    description: '日常生活中常用的英语单词',
    wordCount: 8,
    createdAt: new Date().getTime() - 86400000 * 8,
    updatedAt: new Date().getTime() - 86400000 * 1,
    coverImage: 'https://via.placeholder.com/150',
    isPublic: true,
    words: mockWords.slice(5, 10)
  },
  {
    id: '3',
    name: '商务英语',
    description: '商务场景中常用的英语词汇',
    wordCount: 12,
    createdAt: new Date().getTime() - 86400000 * 6,
    updatedAt: new Date().getTime() - 86400000 * 3,
    coverImage: 'https://via.placeholder.com/150',
    isPublic: false,
    words: []
  }
]

// 模拟学习计划数据
export const mockStudyPlans = [
  {
    id: '1',
    name: '每日学习计划',
    description: '每天学习10个新单词',
    dailyGoal: 10,
    wordSetId: '1',
    startDate: new Date().getTime() - 86400000 * 7,
    endDate: null,
    status: 'active',
    reminderEnabled: true,
    reminderTime: '20:00',
    progress: {
      totalWordsLearned: 45,
      wordsLearnedToday: 8,
      streakDays: 5,
      lastStudyDate: new Date().getTime() - 86400000
    }
  },
  {
    id: '2',
    name: '周末强化',
    description: '周末每天学习20个单词',
    dailyGoal: 20,
    wordSetId: '2',
    startDate: new Date().getTime() - 86400000 * 30,
    endDate: new Date().getTime() - 86400000 * 7,
    status: 'completed',
    reminderEnabled: false,
    reminderTime: '',
    progress: {
      totalWordsLearned: 120,
      wordsLearnedToday: 0,
      streakDays: 10,
      lastStudyDate: new Date().getTime() - 86400000 * 7
    }
  }
]

// 模拟语音设置数据
export const mockVoiceSettings = {
  id: '1',
  voiceId: 'en-US-Wavenet-B',
  languageCode: 'en-US',
  name: 'American English Female',
  speed: 1.0,
  pitch: 1.0,
  volumeGainDb: 0.0,
  isDefault: true,
  engine: 'google',
  lastUsed: new Date().getTime()
}

// 模拟可用语音列表
export const mockVoices = [
  {
    voiceId: 'en-US-Wavenet-A',
    languageCode: 'en-US',
    name: 'American English Male',
    gender: 'male',
    engine: 'google'
  },
  {
    voiceId: 'en-US-Wavenet-B',
    languageCode: 'en-US',
    name: 'American English Female',
    gender: 'female',
    engine: 'google'
  },
  {
    voiceId: 'en-GB-Wavenet-A',
    languageCode: 'en-GB',
    name: 'British English Male',
    gender: 'male',
    engine: 'google'
  },
  {
    voiceId: 'en-GB-Wavenet-B',
    languageCode: 'en-GB',
    name: 'British English Female',
    gender: 'female',
    engine: 'google'
  }
]

// 模拟学习统计数据
export const mockLearningStats = {
  totalWords: 100,
  masteredWords: 45,
  wordsToReview: 20,
  todayWords: 15,
  totalStudyTime: 3600000, // 1小时
  avgStudyTime: 30,
  overallEfficiency: 85,
  retentionRate: 70,
  difficultyDistribution: {
    veryEasy: 10,
    easy: 20,
    medium: 30,
    hard: 25,
    veryHard: 15
  },
  lastStudyDate: new Date().getTime() - 86400000
}

// 模拟学习会话数据
export const mockStudySessions = [
  {
    id: '1',
    startTime: new Date().getTime() - 86400000 - 3600000, // 昨天的1小时学习
    endTime: new Date().getTime() - 86400000, // 昨天结束
    duration: 3600000,
    wordsLearned: 10,
    wordsReviewed: 20,
    totalWordsProcessed: 30,
    efficiency: 90,
    date: new Date(new Date().getTime() - 86400000).toISOString()
  },
  {
    id: '2',
    startTime: new Date().getTime() - 86400000 * 2 - 2700000, // 前天的45分钟学习
    endTime: new Date().getTime() - 86400000 * 2, // 前天结束
    duration: 2700000,
    wordsLearned: 8,
    wordsReviewed: 15,
    totalWordsProcessed: 23,
    efficiency: 85,
    date: new Date(new Date().getTime() - 86400000 * 2).toISOString()
  }
]

// 模拟用户数据
export const mockUser = {
  id: '1',
  username: 'testuser',
  email: 'test@example.com',
  avatar: 'https://via.placeholder.com/100',
  registrationDate: new Date().getTime() - 86400000 * 30,
  learningStats: {
    totalWordsLearned: 150,
    studyDays: 20,
    streakDays: 5,
    averageWordsPerDay: 7.5
  },
  preferences: {
    darkMode: false,
    language: 'zh-CN',
    notificationEnabled: true
  }
}

// 模拟TTS音频URL
export const mockAudioUrl = (text) => {
  // 在实际应用中，这里应该返回真实的音频URL
  return `https://example.com/api/tts/${encodeURIComponent(text)}.mp3`
}

// 模拟API延迟
export const mockDelay = (ms = 500) => {
  return new Promise(resolve => setTimeout(resolve, ms))
}

// 随机生成ID
export const generateMockId = (prefix = 'id') => {
  return `${prefix}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
}

// 随机生成单词学习统计
export const generateWordStats = (wordId) => {
  const now = Date.now()
  const randomDays = Math.floor(Math.random() * 30)
  const lastReviewed = now - 86400000 * randomDays
  const attempts = Math.floor(Math.random() * 10) + 1
  const successes = Math.floor(Math.random() * attempts) + 1
  const masteryLevel = Math.min(Math.floor((successes / attempts) * 5) + 1, 5)
  
  return {
    wordId,
    attempts,
    successes,
    lastReviewed,
    masteryLevel,
    lastStudyDate: lastReviewed,
    studyCount: Math.floor(Math.random() * 5) + 1
  }
}

// 获取模拟的单词学习统计
export const getMockWordStats = () => {
  return mockWords.map(word => generateWordStats(word.id))
}

// 模拟API错误
export const generateMockError = (type = 'SERVER_ERROR') => {
  const errors = {
    NETWORK_ERROR: {
      type: 'NETWORK_ERROR',
      message: '网络连接失败，请检查您的网络设置',
      status: null
    },
    SERVER_ERROR: {
      type: 'SERVER_ERROR',
      message: '服务器内部错误，请稍后再试',
      status: 500
    },
    CLIENT_ERROR: {
      type: 'CLIENT_ERROR',
      message: '请求参数错误',
      status: 400
    },
    AUTH_ERROR: {
      type: 'AUTH_ERROR',
      message: '未授权，请重新登录',
      status: 401
    },
    TIMEOUT_ERROR: {
      type: 'TIMEOUT_ERROR',
      message: '请求超时，请稍后再试',
      status: 408
    },
    UNKNOWN_ERROR: {
      type: 'UNKNOWN_ERROR',
      message: '未知错误',
      status: null
    }
  }
  
  return errors[type] || errors.UNKNOWN_ERROR
}